<template>
    <div>
        <h1>登录页面</h1>
        <van-field label="用户名" v-model="name" />
        <van-field label="密码" v-model="password" />
        <van-button @click="login">登录</van-button>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                name:'',
                password:''
            }
        },
        methods: {
            login(){
                this.$axios.post('/klogin/',{'name':this.name,'password':this.password}).then(res=>{
                    if(res.data.code == 200){
                        localStorage.setItem('userid',res.data.userid)
                        this.$router.push('kshowgoods')
                    }
                })
            }
        },
    }
</script>

<style scoped>

</style>